

* compute p value for Hausman test for Table 3

***Inputs: 
 * $Data/GameUserWPdaily_norm.dta
 * $Data/maxmindirectionsmonth_zip260.dta
 
*** Outputs: 
 * $Results/Hausman_linear
 * $Results/Hausman_highpm
 * $Results/Hausman_linear_pctile
 * $Results/Hausman_highpm_pctile

 

	use $Data/GameUserWPdaily_norm.dta, clear
	
	gen month = month(date)

		
	gen zip2 = int( zip/10)
	
	merge m:1 zip2 month using $Data/maxmindirectionsmonth_zip260.dta
	
	keep if _merge ==3
	
	
	gen monthyear = mofd(date)

	gen highpm =  weighted_dailypm > 25 & weighted_dailypm<. 

	
	egen cut_winddirection = cut(median_closestwind), at(0(60)360)
	replace cut_winddirection = 0 if median_closestwind ==360
	
	gen maxzipwind = (cut_winddirection ==maxdirection )
	replace maxzipwind = . if maxdirection==.
	
	keep if maxzipwind<. 
	

	
		egen cut_temp = cut(weighted_temperature), at(-40(10)40)

	
	
	quietly tab cut_temp, gen(temps)
	
	by monthyear, sort: center norm_score weighted_dailypm maxzipwind weighted_wind_speed weighted_precipitation temps* highpm score_pctile
	
	

xi: xtivreg2 c_norm_score (c_weighted_dailypm  =c_maxzipwind )  c_weighted_wind_speed c_weighted_precipitation c_temps* ,  fe cluster(anon_id monthyear) endog(c_weighted_dailypm)

eststo all2 

estimates save $Results/Hausman_linear , replace

xi: xtivreg2 c_norm_score (c_highpm =c_maxzipwind )  c_weighted_wind_speed c_weighted_precipitation c_temps* , fe cluster(anon_id monthyear) endog(c_highpm)

eststo all3 

estimates save $Results/Hausman_highpm , replace



xi: xtivreg2  c_score_pctile (c_weighted_dailypm  =c_maxzipwind )  c_weighted_wind_speed c_weighted_precipitation c_temps* , endog(c_weighted_dailypm) fe cluster(anon_id monthyear)

eststo pctile1

estimates save $Results/Hausman_linear_pctile , replace


xi: xtivreg2  c_score_pctile (c_highpm =c_maxzipwind )  c_weighted_wind_speed c_weighted_precipitation c_temps*  , endog(c_highpm) fe cluster(anon_id monthyear)

eststo pctile2 


estimates save $Results/Hausman_highpm_pctile , replace

